import { socketExecute } from "../utils";
import { socketServer } from "../utils";

import axios from "axios";

const instance = axios.create({
   baseURL: 'http://localhost:8001/',
   timeout: 1000,
   headers: {'X-Custom-Header': 'foobar'}
});

export default {

   connectAI : () => socketServer.connect(),
   connectEX : () => socketExecute.connect(),
   sendAIMessage: (data)=> socketServer.sendMessage(data),
   sendEXMessage: (data)=> socketExecute.sendMessage(data),

   get : {
      modelList :()=> instance.get('/matchList'),
      wordList : ()=>instance.get('/wordList'),
      meaning : (message) => instance.get('/getMeaning/'+message),
      sWordList : ()=>instance.get('/sWordList'),
      conceptList : ()=>instance.get('/conceptList'),
   },
   add :{
      word :(data)=>instance.post('/addWord',data),
      concept :(data)=>instance.post('/addConcept',data),
      sWord :(data)=>instance.post('/addSWord',data),
      match :(data)=>instance.post('/addMatch',data),
   },
   del :{
      word :(data)=>instance.delete('/word',data),
      concept :(data)=>instance.delete('/concept',data),
      sWord :(data)=>instance.delete('/sWord',data),
      match :(data)=>instance.delete('/match',data),
   },
   change :{
      word :(data)=>instance.post('/change',data),
      concept :(data)=>instance.post('/change',data),
      sWord :(data)=>instance.post('/sWord',data),
      match :(data)=>instance.post('/match',data),
   }
}